	*===========================*
	* Table 16 - teacher FE results
	*===========================*

local r=1
eststo clear
estimates clear
foreach outcomevar of varlist read_std math_std {
		
		
		preserve
	
		if "`outcomevar'" == "math_std" {
			keep if subject == "Math"
			local outcomename "m"
			global outcomename "m"
			}
		else if "`outcomevar'" == "read_std" {
			keep if subject == "ELA"
			local outcomename "r"
			global outcomename "r"
			}
		
		
			
				
				eststo model`r': areg `outcomevar' $nothreatvars $prevvars $gradevar i.year i.sch_id $yeardosevar , absorb(id) vce(cluster _id_year)
				global my_cmd `e(cmdline)'
				global my_num `r'
				if "$do_ri" != "NO"{
					do "$code_dir\Randomization Inference.do"
					}
				local r=`r'+1
				
				
				eststo model`r': areg `outcomevar' $ntvars_23 $prevvars $gradevar $experiencevar $sdemovars i.year i.sch_id $yeardosevar , absorb(id) vce(cluster _id_year)
				global my_cmd `e(cmdline)'
				global my_num `r'
				if "$do_ri" != "NO"{
					do "$code_dir\Randomization Inference.do"
					}
				local r=`r'+1
				
				
				
				eststo model`r': areg `outcomevar' $ntvars_23 $prevvars $gradevar $feedbackvars $experiencevar $sdemovars i.year i.sch_id $yeardosevar , absorb(id) vce(cluster _id_year)
				global my_cmd `e(cmdline)'
				global my_num `r'
				if "$do_ri" != "NO"{
					do "$code_dir\Randomization Inference.do"
					}
				local r=`r'+1
			
				
				local namevar "linear"
				
		
		restore
		}



if strpos("$nothreatvars","i.year") | strpos("$nothreatvars", "i.grade") | strpos("$nothreatvars","i.exp0") {
				local keepvars "*nothreat_*"
				} 
			else {
				local keepvars $nothreatvars $probvars $feedbackvars
				}


if "$tablenum" == "Table_16"{
			
			
			estfe model*, labels(id "Teacher FE")
			return list
			*`r(indicate_fe)' "School FE=*.sch_id" "Year FE = *.year" "Grade FE = *grade*" 
			esttab model* using "$output_dir\Tables\\_${tablenum}_both_COMPLETE.tex", ///
				indicate("Previous Student Scores = math_std_t" ///
					"Teacher Experience=*xp*" "Student Demographics = *.male" , labels("X" " ")) ///
				cells("b(${stars} fmt(%5.4fc) label(!))" "se(par fmt(%5.4fc) label(!))" "LB(fmt(%5.4fc) par(zz ) label(!)) & UB(fmt(%5.4fc) par(qq ww) label(!))") ///
				keep(`keepvars', relax) substitute(zz "[" qq " " ww "]" ! " " / "") starlevels(\$^+\$ 0.10 * 0.05 ** 0.01 *** 0.001) gaps nonotes ///
				mgroups(Reading Math, pattern(1 0 0 1 0 0)                   ///
					prefix(\multicolumn{@span}{c}{) suffix(})   ///
					span erepeat(\cmidrule(lr){@span}))         ///
				label nodepvars eqlabels(none) nomtitles nolegend replace 
			estfe model*, restore	
			
			
			estfe model*, labels(id "Teacher FE")
			return list
			*`r(indicate_fe)' "School FE=*.sch_id" "Year FE = *.year" "Grade FE = *grade*"
			esttab model* using "$output_dir\Tables\\_${tablenum}_both.tex", ///
				indicate( "Previous Student Scores = math_std_t" ///
					       "Teacher Experience=*xp*" "Student Demographics = *.male" "Feedback Time=postconf_*" , labels("X" " ")) ///
				cells("b(${stars} fmt(%5.4fc) label(!))" "se(par fmt(%5.4fc) label(!))" "LB(fmt(%5.4fc) par(zz ) label(!)) & UB(fmt(%5.4fc) par(qq ww) label(!))") ///
				keep(`keepvars', relax) substitute(zz "[" qq " " ww "]" ! " " / "") starlevels(\$^+\$ 0.10 * 0.05 ** 0.01 *** 0.001) gaps nonotes ///
				mgroups(Reading Math, pattern(1 0 0 1 0 0)                   ///
					prefix(\multicolumn{@span}{c}{) suffix(})   ///
					span erepeat(\cmidrule(lr){@span}))         ///
				label nodepvars eqlabels(none) nomtitles nolegend  replace
			estfe model*, restore	
			
			* add standard p-values
			estfe model*, labels(id "Teacher FE")
			return list
			esttab model* using "$output_dir\Tables\\_${tablenum}_both_pvalues.tex", ///
				indicate( "Previous Student Scores = math_std_t" ///
					       "Teacher Experience=*xp*" "Student Demographics = *.male" "Feedback Time=postconf_*" , labels("X" " ")) ///
				cells("b(${stars} fmt(%5.4fc) label(!))" "se(par fmt(%5.4fc) label(!))" "p(par(zz ww) fmt(%5.4fc)  label(!))") ///
				keep(`keepvars', relax) substitute(zz "[" qq " " ww "]" ! " " / "") starlevels(\$^+\$ 0.10 * 0.05 ** 0.01 *** 0.001) gaps nonotes ///
				mgroups(Reading Math, pattern(1 0 0 1 0 0)                   ///
					prefix(\multicolumn{@span}{c}{) suffix(})   ///
					span erepeat(\cmidrule(lr){@span}))         ///
				label nodepvars eqlabels(none) nomtitles nolegend  replace
			estfe model*, restore	
		}
		else if "$tablenum" == "Table_A02" {
			if "$do_ri" == "YES" {
				estfe model*, labels(id "Teacher FE")
				return list
				*`r(indicate_fe)' "School FE=*.sch_id" "Year FE = *.year" "Grade FE = *grade*"
				esttab model* using "$output_dir\Tables\\_${tablenum}_both.tex", ///
					indicate( "Previous Student Scores = math_std_t" ///
							   "Teacher Experience=*xp*" "Student Demographics = *.male", labels("X" " ")) ///
					cells("b(${stars} fmt(%5.4fc) label(!))" "se(par fmt(%5.4fc) label(!))" "LB(fmt(%5.4fc) par(zz ) label(!)) & UB(fmt(%5.4fc) par(qq ww) label(!))") ///
					keep(`keepvars', relax) substitute(zz "[" qq " " ww "]" ! " " / "") gaps starlevels(\$^+\$ 0.10 * 0.05 ** 0.01 *** 0.001) nonotes ///
					mgroups(Reading Math, pattern(1 0 1 0 )                   ///
						prefix(\multicolumn{@span}{c}{) suffix(})   ///
						span erepeat(\cmidrule(lr){@span}))         ///
					label nodepvars eqlabels(none) mtitles("All Students" "No Suspensions" "All Students" "No Suspensions")  nolegend replace
				estfe model*, restore	
			}
			else {
				estfe model*, labels(id "Teacher FE")
				return list
				*`r(indicate_fe)' "School FE=*.sch_id" "Year FE = *.year" "Grade FE = *grade*"
				esttab model* using "$output_dir\Tables\\_${tablenum}_both_pval.tex", ///
					indicate( "Previous Student Scores = math_std_t" ///
							   "Teacher Experience=*xp*" "Student Demographics = *.male", labels("X" " ")) ///
					cells("b(${stars} fmt(%5.4fc) label(!))" "se(par fmt(%5.4fc) label(!))" "p(par(zz ww) fmt(%5.4fc)  label(!))") ///
					keep(`keepvars', relax) substitute(zz "[" qq " " ww "]" ! " " / "") gaps starlevels(\$^+\$ 0.10 * 0.05 ** 0.01 *** 0.001) nonotes ///
					mgroups(Reading Math, pattern(1 0 1 0 )                   ///
						prefix(\multicolumn{@span}{c}{) suffix(})   ///
						span erepeat(\cmidrule(lr){@span}))         ///
					label nodepvars eqlabels(none) mtitles("All Students" "No Suspensions" "All Students" "No Suspensions")  nolegend replace
				estfe model*, restore	
			}
		}
		else if "$tablenum" == "Table_A05" {
			if "$do_ri" == "YES" {
				estfe model*, labels(id "Teacher FE")
				return list
				*`r(indicate_fe)' "School FE=*.sch_id" "Year FE = *.year"
				esttab model* using "$output_dir\Tables\\_${tablenum}_both.tex", ///
					indicate( "Previous Student Scores = math_std_t" ///
							   "Teacher Experience=*xp*" "Student Demographics = *.male" "Feedback Time=postconf_*" , labels("X" " ")) ///
					cells("b(${stars} fmt(%5.4fc) label(!))" "se(par fmt(%5.4fc) label(!))" "LB(fmt(%5.4fc) par(zz ) label(!)) & UB(fmt(%5.4fc) par(qq ww) label(!))") ///
					keep( *nothreat_cycle3* , relax) substitute(zz "[" qq " " ww "]" ! " " / "") gaps starlevels(\$^+\$ 0.10 * 0.05 ** 0.01 *** 0.001) nonotes ///
					mgroups(Reading Math, pattern(1 0 0 1 0 0)                   ///
						prefix(\multicolumn{@span}{c}{) suffix(})   ///
						span erepeat(\cmidrule(lr){@span}))         ///
					label nodepvars eqlabels(none) nomtitles  nolegend replace
				estfe model*, restore	
			}
			else {
				estfe model*, labels(id "Teacher FE")
				return list
				esttab model* using "$output_dir\Tables\\_${tablenum}_both_pval.tex", ///
					indicate( "Previous Student Scores = math_std_t" ///
							   "Teacher Experience=*xp*" "Student Demographics = *.male" "Feedback Time=postconf_*" , labels("X" " ")) ///
					cells("b(${stars} fmt(%5.4fc) label(!))" "se(par fmt(%5.4fc) label(!))" "p(par(zz ww) fmt(%5.4fc)  label(!))") ///
					keep( *nothreat_cycle3* , relax) substitute(zz "[" qq " " ww "]" ! " " / "") gaps starlevels(\$^+\$ 0.10 * 0.05 ** 0.01 *** 0.001) nonotes ///
					mgroups(Reading Math, pattern(1 0 0 1 0 0)                   ///
						prefix(\multicolumn{@span}{c}{) suffix(})   ///
						span erepeat(\cmidrule(lr){@span}))         ///
					label nodepvars eqlabels(none) nomtitles  nolegend replace
				estfe model*, restore	
			}
		}
		else if "$tablenum" == "Table_A06" {
			if "$do_ri" == "YES" {
				estfe model*, labels(id "Teacher FE")
				return list
				esttab model* using "$output_dir\Tables\\_${tablenum}_both.tex", ///
					cells("b(${stars} fmt(%5.4fc) label(!))" "se(par fmt(%5.4fc) label(!))" "LB(fmt(%5.4fc) par(zz ) label(!)) & UB(fmt(%5.4fc) par(qq ww) label(!))") ///
					indicate("Previous Student Scores = math_std_t" ///
						"Teacher Experience = *xp_capped" "Student Demographics= *.male" "Feedback Time=*conf_*" , labels("X" " ")) ///
					keep(`keepvars') substitute(zz "[" qq " " ww "]" ! " " / "") gaps starlevels(\$^+\$ 0.10 * 0.05 ** 0.01 *** 0.001) nonotes ///
					mgroups(Reading Math, pattern(1 0 0 1 0 0)                   ///
						prefix(\multicolumn{@span}{c}{) suffix(})   ///
						span erepeat(\cmidrule(lr){@span}))         ///
					label nodepvars eqlabels(none) nomtitles  nolegend replace
				estfe model*, restore	
			}
			else {
				estfe model*, labels(id "Teacher FE")
				return list
				esttab model* using "$output_dir\Tables\\_${tablenum}_both_pval.tex", ///
					cells("b(${stars} fmt(%5.4fc) label(!))" "se(par fmt(%5.4fc) label(!))" "p(par(zz ww) fmt(%5.4fc)  label(!))") ///
					indicate("Previous Student Scores = math_std_t" ///
						"Teacher Experience = *xp_capped" "Student Demographics= *.male" "Feedback Time=*conf_*" , labels("X" " ")) ///
					keep(`keepvars') substitute(zz "[" qq " " ww "]" ! " " / "") gaps starlevels(\$^+\$ 0.10 * 0.05 ** 0.01 *** 0.001) nonotes ///
					mgroups(Reading Math, pattern(1 0 0 1 0 0)                   ///
						prefix(\multicolumn{@span}{c}{) suffix(})   ///
						span erepeat(\cmidrule(lr){@span}))         ///
					label nodepvars eqlabels(none) nomtitles  nolegend replace
				estfe model*, restore	
			}
		}
		else if "$tablenum" == "Table_A04" {
			estfe model*, labels(id "Teacher FE")
			return list
			*`r(indicate_fe)' "School FE=*.sch_id" "Year FE = *.year" "Grade FE = *grade*" 
			esttab model* using "$output_dir\Tables\\_${tablenum}_both.tex", ///
				indicate( "Previous Student Scores = math_std_t" ///
					       "Teacher Experience=*xp*" "Student Demographics = *.male" "Feedback Time=postconf_*" , labels("X" " ")) ///
				cells("b(${stars} fmt(%5.4fc) label(!))" "se(par fmt(%5.4fc) label(!))" "LB(fmt(%5.4fc) par(zz ) label(!)) & UB(fmt(%5.4fc) par(qq ww) label(!))") ///
				keep(`keepvars', relax) substitute(zz "[" qq " " ww "]" ! " " / "") gaps starlevels(\$^+\$ 0.10 * 0.05 ** 0.01 *** 0.001) nonotes ///
				mgroups(Reading Math, pattern(1 0 0 1 0 0)                   ///
					prefix(\multicolumn{@span}{c}{) suffix(})   ///
					span erepeat(\cmidrule(lr){@span}))         ///
				label nodepvars eqlabels(none) nomtitles  nolegend replace
			estfe model*, restore	
		}
		else if "$tablenum" == "Table_A07" {
			estfe model*, labels(id "Teacher FE")
			return list
			*
			esttab model* using "$output_dir\Tables\\_${tablenum}_both.tex", ///
				indicate( "Previous Student Scores = math_std_t" ///
					       "Teacher Experience=*xp*" "Student Demographics = *.male" "Feedback Time=postconf_*" , labels("X" " ")) ///
				cells("b(${stars} fmt(%5.4fc) label(!))" "se(par fmt(%5.4fc) label(!))" "LB(fmt(%5.4fc) par(zz ) label(!)) & UB(fmt(%5.4fc) par(qq ww) label(!))") ///
				keep(`keepvars', relax) substitute(zz "[" qq " " ww "]" ! " " / "") gaps starlevels(\$^+\$ 0.10 * 0.05 ** 0.01 *** 0.001) nonotes ///
				mgroups(Reading Math, pattern(1 0 0 1 0 0)                   ///
					prefix(\multicolumn{@span}{c}{) suffix(})   ///
					span erepeat(\cmidrule(lr){@span}))         ///
				label nodepvars eqlabels(none) nomtitles  nolegend replace
			estfe model*, restore	
		}
		else {
			estfe model*, labels(id "Teacher FE")
			return list
			*
			esttab model* using "$output_dir\Tables\\_${tablenum}_both.tex", ///
				indicate( "Previous Student Scores = math_std_t" ///
					       "Teacher Experience=*xp*" "Student Demographics = *.male" "Feedback Time=postconf_*" , labels("X" " ")) ///
				cells("b(${stars} fmt(%5.4fc) label(!))" "se(par fmt(%5.4fc) label(!))" "LB(fmt(%5.4fc) par(zz ) label(!)) & UB(fmt(%5.4fc) par(qq ww) label(!))") ///
				keep(`keepvars', relax) substitute(zz "[" qq " " ww "]" ! " " / "") gaps starlevels(\$^+\$ 0.10 * 0.05 ** 0.01 *** 0.001) nonotes ///
				label nodepvars eqlabels(none) nomtitlesgend replace
			estfe model*, restore	
		}